package net.sf.appia.jgcs.protocols.services;

import net.sf.appia.core.Layer;
import net.sf.appia.core.Session;
import net.sf.appia.core.events.channel.ChannelInit;
import net.sf.appia.protocols.group.events.GroupSendableEvent;
import net.sf.appia.protocols.group.intra.View;



/**
 * LoopBackLayer is the Layer that sends back a copy of the 
 * GroupSendableEvents received from the upper Layers.
 * This is intedende to simulate Broadcast funcionality and
 * it's useful for implementing Atomic Broadcast protocols.<p>
 * This Layer should be placed above the group communication layers
 * and doesn't provide uniform guarantees.
 * This protocol accepts the following events:<p>
 * <ul>
 * <li>GroupSendableEvent
 * <li>ChannelInit
 * </ul>
 * @see net.sf.appia.protocols.group.events.GroupSendableEvent
 * @see net.sf.appia.core.events.channel.ChannelInit
 */
public class FifoLoopBackLayer extends Layer {

    /**
     * A simple constructor.
     */
    public FifoLoopBackLayer() {

    	// Events that the protocol needs.
    	evRequire=new Class[]{
    	        GroupSendableEvent.class,
        };
    	
    	// Events that the protocol accepts.
    	evAccept=new Class[]{
    	        evRequire[0],
    	        ChannelInit.class,
    	        View.class,
        };
    	
    	// Events provided by this layer
    	evProvide=new Class[]{
    	        evRequire[0],
        };
    }

    /**
     * Standard session instantiation
     */
    public Session createSession() {
        return new FifoLoopBackSession(this);
    }

}
    